define(["jquery"],function($){
	return {
		init:function(obj1,obj2){
			obj1.on("keyup",function(){
				$.ajax({
			        url: "http://suggestion.baidu.com/su",
			        dataType: "jsonp",
			        data: {		          	
			           wd:obj1.val()
		        	},
			        jsonp:"cb",
		          	success: function(res) {
						//res为object
						var arr=res.s;
						var str="";
						for(var i in arr){
							if(arr[i].indexOf(obj1.val())!==-1){
								str+=`<li>${arr[i]}</li>`;
							}
						}
						obj2.html(str);	            	
	           		}
	       		});
			})
		    //搜索框事件  		       		
	        obj1.focus(function(){
	        	$(this).css({
	        		"background":"#fff",
	        		"color":"#444"
	        	}).siblings(".searchCon").show();
	        })
	        obj1.blur(function(){
	        	$(this).css({
	        		"background":"#e0e0e0",	
	        		"color":"#727272"
	        	}).siblings(".searchCon").hide();
	        })
	        //下拉划过变色
	        obj2.on("mouseover","li",function(){
	        		$(this).css({
	        			"background":"#5aaa16"
	        		})
	        })
	        obj2.on("mouseout","li",function(){
	        		$(this).css({
	        			"background":"#fff"
	        		})
	        })
	        //点击取内容
	        obj2.on("click","li",function(){
	        	obj1.val($(this).html())
	        	obj2.hide()
	        })
	    }
	}
			
})
 